package com.wei.czz.common.enums.common.fileImport;

import com.wei.czz.common.dto.common.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2024-05-05 10:58:10
 * className: UploadStatusEnum
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum UploadStatusEnum {

    /*
        0-新建 1-上传中 2-暂停 3-上传成功 4-上传失败
     */
    CREATE(0, "新建"),

    UPLOAD(1, "上传中"),

    PAUSE(2, "暂停"),

    SUCCESS(3, "上传成功"),

    FAIL(4, "上传失败"),

    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取名称
     * @param value 值
     * @return 名称
     */
    public static String getName(Integer value) {
        for (UploadStatusEnum uploadStatusEnum : values()) {
            if (uploadStatusEnum.value.equals(value)) {
                return uploadStatusEnum.name;
            }
        }
        return "";
    }

    /**
     * 获取枚举列表
     */
    public static List<NameValue<Integer>> getList() {
        return Stream.of(values())
                .map(uploadStatusEnum -> new NameValue<>(uploadStatusEnum.name, uploadStatusEnum.value))
                .collect(Collectors.toList());
    }
}
